home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
windows
/
wdj1096.zip
/
ZOLMAN.ZIP
/
ZVBDLG.ZIP
/
ZSPIN.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-16
|
4KB
|
132 lines
/*
File: ZSpin.cpp
Author: Raja
Date: Jan 16, 1996
Implementation file for ZSpin class which handles Spin up and spin down
notifications.
*/
#include "stdafx.h"
#include "zspin.h"
#include "stdlib.h"
#define MAX_LENGTH 40
IMPLEMENT_DYNAMIC (ZSpin, CVBControl)
// Required for SubclassVBControl
typedef CVBControl* __based((__segment)_self)* FAR* CVBHandle;
#define new DEBUG_NEW
BEGIN_MESSAGE_MAP(ZSpin, CVBControl)
//{{AFX_MSG_MAP(ZSpin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// Register VBX events.
UINT NEAR ZSPIN_VBN_SPINDOWN = AfxRegisterVBEvent("SPINDOWN");
UINT NEAR ZSPIN_VBN_SPINUP = AfxRegisterVBEvent("SPINUP");
/**************************************************************************/
// OnChildNotify - CWnd virtual function override
// Refer to MFC documentation for details on parameters and return values
// Handle the WM_VBXEVENT to process the SpinUp and SpinDown events.
/**************************************************************************/
BOOL ZSpin::OnChildNotify (UINT message, WPARAM wParam, LPARAM lParam,
LRESULT *pLResult)
{
AFX_VBXEVENTPARAMS *pParams;
int nVal;
char szBuffer [MAX_LENGTH];
switch (message) {
case WM_VBXEVENT:
pParams = (AFX_VBXEVENTPARAMS FAR*)lParam;
if (pParams->nNotifyCode == ZSPIN_VBN_SPINUP) {
::GetWindowText (m_hWndEdit, szBuffer, MAX_LENGTH);
nVal = atoi (szBuffer);
wsprintf (szBuffer, "%d", nVal + 1);
::SetWindowText (m_hWndEdit, szBuffer);
}
else if (pParams->nNotifyCode == ZSPIN_VBN_SPINDOWN) {
::GetWindowText (m_hWndEdit, szBuffer, MAX_LENGTH);
nVal = atoi (szBuffer);
wsprintf (szBuffer, "%d", nVal - 1);
::SetWindowText (m_hWndEdit, szBuffer);
}
return TRUE;
}
return CVBControl::OnChildNotify(message, wParam, lParam, pLResult);
}
/**************************************************************************/
// SubclassVBControl - copied from subvbctl.cpp in SUBVBX project (MSDN).
// Parameters: Parent CWnd pointer, control id, whether embedded (TRUE).
// Returns: TRUE on success, FALSE otherwise.
// Note: Slight changes from original - return values.
/**************************************************************************/
BOOL ZSpin::SubclassVBControl(CWnd* pParent, UINT idChild,
BOOL bEmbedded)
{
ASSERT(pParent != NULL);
ASSERT(idChild != 0 && idChild != -1);
// Get the existing CVBControl. Cast it to this class type
// so that we will have access to the protected data
ZSpin * pControl = (ZSpin *)pParent->GetDlgItem (idChild);
if (!pControl)
return FALSE;
ASSERT(pControl->IsKindOf(RUNTIME_CLASS(CVBControl)));
// Copy over all of the appropriate data
m_pModel = pControl->m_pModel;
m_bRecreating = pControl->m_bRecreating;
m_bInPostNcDestroy = pControl->m_bInPostNcDestroy;
m_bLoading = pControl->m_bLoading;
m_nCursorID = pControl->m_nCursorID;
m_nInitialStack = pControl->m_nInitialStack;
m_nRecursionLevel = pControl->m_nRecursionLevel;
m_bStackFault = pControl->m_bStackFault;
m_nFaultRecurse = pControl->m_nFaultRecurse;
m_hbrBkgnd = pControl->m_hbrBkgnd;
m_hFontCreated = pControl->m_hFontCreated;
m_hcurMouse = pControl->m_hcurMouse;
m_hCtl = pControl->m_hCtl;
m_clrBkgnd = pControl->m_clrBkgnd;
m_clrFore = pControl->m_clrFore;
m_rectCreate = pControl->m_rectCreate;
m_strTag = pControl->m_strTag;
m_bAutoDelete = !bEmbedded;
// Clear data in the old CVBControl that would cause problems
pControl->m_hFontCreated = NULL;
pControl->m_hbrBkgnd = NULL;
pControl->m_hcurMouse = NULL;
pControl->m_pModel = NULL;
pControl->m_hCtl = NULL;
CVBHandle hpControl = (CVBHandle) m_hCtl;
**hpControl = this;
pControl->m_hFontCreated=NULL;
pControl->m_hbrBkgnd=NULL;
pControl->m_hcurMouse=NULL;
// Transfer hWnd
Attach(pControl->Detach());
// Delete old object if necessary
if (pControl->m_bAutoDelete)
delete pControl;
return TRUE;
}